In [ ]:
class WordProcessor():
PLUGINS = []
@classmethod
def register(cls, function):
cls.PLUGINS.append(function)
@classmethod
def process(cls, text):
for plugin in cls.PLUGINS:
text =plugin(text)
return text
@WordProcessor.register
def strip_text(text):
return text.strip()
@WordProcessor.register
def capitalize_text(text):
return text.capitalize()
WordProcessor.process(" ala ma kota ") # -> "Ala ma kota"